package com.hspedu.codeblock;

/**
 * @Author Stringzhua
 * @Date 2024/3/5 18:54
 * description:看代码输出什么?
 * result:
 * in static block
 * 100
 * 100
 */
public class CodeBlockExercise01 {
    public static void main(String[] args) {
        System.out.println("Person.total = " + Person.total);//2 100
        System.out.println("Person.total = " + Person.total);//3 100
    }
}

class Person {
    public static int total;//静态变量

    static {//静态代码块
        total = 100;
        System.out.println("in static block!");//1
    }
}